package net.aaa.hotel.dao.impl;

import net.aaa.hotel.dao.DingDanDao;
import net.aaa.hotel.entity.Custom;
import net.aaa.hotel.util.BaseDB;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class DingDanImpl implements DingDanDao {
    @Override
    public List<Map> query(Map custom) {
//        System.out.println("ididid"+custom.get("id"));
        String sql = "SELECT o.*, count(r.orderid) a , count(t.orderid) b " +
                " FROM t_order o LEFT JOIN t_ruzhudetail r ON o.id = r.orderid " +
                " LEFT JOIN t_tuifang t on t.ruzhuid = r.id "+
                " where uid="+custom.get("id") +" GROUP BY o.id";
        return BaseDB.queryMap(sql);
    }

    @Override
    public List<Map> qqq(Integer id) {
        return BaseDB.queryMap("select r.id, r.orderid,tr.roomcode,r.uname,r.tel,r.indate,o.leavedate, r.status rstatus \n" +
                "from t_ruzhudetail r \n" +
                "\t\t,t_order o\n" +
                "\t\t,t_type t\n" +
                "\t\t,t_room tr\n" +
                "where \n" +
                "\tr.orderid = o.id \n" +
                "and\n" +
                "\to.roomtype = t.id\n" +
                "and \n" +
                "\to.`status` in (0,1,2,10) \n" +
                "and \n" +
                "\t r.`status`!=3 \n" +
                "and \n" +
                "\ttr.id=r.roomid\n" +
                " and o.id=?",id );
    }
}
